package com.aiyige.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zhuyakun on 2017/10/24.
 */

public class DateFormatUtil {

    public static String formatMS(String pattern, Long millisecond) {
        if (millisecond == null) return "";
        return format(pattern, new Date(millisecond));
    }

    public static String formatS(String pattern, Long second) {
        if (second == null) return "";
        return formatMS(pattern, second * 1000);
    }

    public static String format(String pattern, Date date) {
        if (date == null) return "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.format(date);
    }

    /**
     * 将时间戳转为代表"距现在多久之前"的字符串
     *
     * @param timeStr 时间戳
     * @return
     */
    public static String getStandardDate(long timeStr) {

        return TimeUtils.getStandardDate(timeStr + "");
    }


}
